package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.client.ItemFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

/**
 * @author XIN
 * 2023/4/25
 */
@Controller
@SuppressWarnings("all")
public class ItemController {
	@Autowired
	private ItemFeignClient itemFeignClient;
	
	@GetMapping("/{skuId}.html")
	public String itemHtml(@PathVariable long skuId, Model model) {
		Result<Map> itemInfo = itemFeignClient.getItemInfo(skuId);
		model.addAllAttributes(itemInfo.getData());
		return "/item/item";
	}
}
